/**
 * 
 */
package org.jft.datamodel.database.dao;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Session;
import org.jft.datamodel.database.HibernateUtil;
import org.jft.datamodel.database.mapping.Person;


/**
 * @author LAP
 *
 */
public abstract class GenericDAO<T> {
	public void add(T value) throws SQLException {
		Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.save(value);
		session.getTransaction().commit();
	}
	public void update(T value) throws SQLException {
		Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.update(value);
		session.getTransaction().commit();
	}
	public abstract T getByID(Long id) throws SQLException;
	public abstract List<T> getAll() throws SQLException;
	public void delete(T value) throws SQLException {
		Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
		session.beginTransaction();
		session.delete(value);
		session.getTransaction().commit();
	}
}
